package com.designpattern.decorator;

/**
 * 项目名称: java_algorithm
 * @ClassName DecoratorTest
 * @Description
 * @Author huipanxing huipanxing@chinasofti.com   @Date 2021/9/9 16:39
 */
public class DecoratorTest {

    public static void main(String[] args) {
        Component component=new ConreteDecorator2(new ConreteDecorator1(new ConcreteComponent()));
        component.operation();
    }
}

interface Component{
    void operation();
}

class ConcreteComponent implements Component{

    @Override
    public void operation() {
        System.out.println("拍照");
    }
}

abstract class Decorator implements Component{
    Component component;

    public Decorator(Component component) {
        this.component = component;
    }
}

class ConreteDecorator1 extends Decorator{

    public ConreteDecorator1(Component component) {
        super(component);
    }

    @Override
    public void operation() {
        component.operation();
        System.out.println("添加美颜");
    }
}

class ConreteDecorator2 extends Decorator{

    public ConreteDecorator2(Component component) {
        super(component);
    }

    @Override
    public void operation() {
        component.operation();
        System.out.println("添加滤镜");
    }
}